/**
 * 
 */
package com.hfjyz.exam.servlet;

import javax.servlet.ServletContextEvent;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.ContextLoaderListener;

import com.hfjyz.exam.dao.MasterDao;
import com.hfjyz.exam.util.MasterUtil;

/**
 *
 */
public class ExamContextLoaderListener extends ContextLoaderListener {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.web.context.ContextLoaderListener#contextInitialized
	 * (javax.servlet.ServletContextEvent)
	 */
	@Override
	public void contextInitialized(ServletContextEvent event) {
		super.contextInitialized(event);
		MasterDao masterDao = (MasterDao) ContextLoader
				.getCurrentWebApplicationContext().getBean("masterDao");
		try {
			MasterUtil.getInstance().init(masterDao.listAll());
		} catch (Exception e) {
		}

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.web.context.ContextLoaderListener#contextDestroyed
	 * (javax.servlet.ServletContextEvent)
	 */
	@Override
	public void contextDestroyed(ServletContextEvent event) {
		super.contextDestroyed(event);
	}

}
